load("//bazel:tachyon_cc.bzl", "tachyon_cc_library", "tachyon_cc_unittest")

package(default_visibility = ["//visibility:public"])

filegroup(
    name = "sp1_hdrs",
    srcs = [
        "baby_bear_poseidon2_commitment_vec.h",
        "baby_bear_poseidon2_constants.h",
        "baby_bear_poseidon2_domains.h",
        "baby_bear_poseidon2_duplex_challenger.h",
        "baby_bear_poseidon2_field_merkle_tree.h",
        "baby_bear_poseidon2_field_merkle_tree_vec.h",
        "baby_bear_poseidon2_fri_proof.h",
        "baby_bear_poseidon2_lde_vec.h",
        "baby_bear_poseidon2_opened_values.h",
        "baby_bear_poseidon2_opening_points.h",
        "baby_bear_poseidon2_two_adic_fri.h",
    ],
)

tachyon_cc_library(
    name = "baby_bear_poseidon2_constants",
    hdrs = ["baby_bear_poseidon2_constants.h"],
)

tachyon_cc_library(
    name = "baby_bear_poseidon2_commitment_vec",
    srcs = ["baby_bear_poseidon2_commitment_vec.cc"],
    hdrs = [
        "baby_bear_poseidon2_commitment_vec.h",
        "baby_bear_poseidon2_commitment_vec_type_traits.h",
    ],
    deps = [
        ":baby_bear_poseidon2_constants",
        "//tachyon/c:export",
        "//tachyon/c/base:type_traits_forward",
        "//tachyon/c/math/finite_fields/baby_bear",
    ],
)

tachyon_cc_library(
    name = "baby_bear_poseidon2_domains",
    srcs = ["baby_bear_poseidon2_domains.cc"],
    hdrs = [
        "baby_bear_poseidon2_domains.h",
        "baby_bear_poseidon2_domains_type_traits.h",
    ],
    deps = [
        "//tachyon/c:export",
        "//tachyon/c/base:type_traits_forward",
        "//tachyon/c/math/finite_fields/baby_bear",
        "//tachyon/crypto/commitments/fri:two_adic_multiplicative_coset",
    ],
)

tachyon_cc_library(
    name = "baby_bear_poseidon2_duplex_challenger",
    srcs = ["baby_bear_poseidon2_duplex_challenger.cc"],
    hdrs = [
        "baby_bear_poseidon2_duplex_challenger.h",
        "baby_bear_poseidon2_duplex_challenger_type_traits.h",
    ],
    deps = [
        ":baby_bear_poseidon2_constants",
        ":baby_bear_poseidon2_hintable",
        "//tachyon/base:auto_reset",
        "//tachyon/base/buffer",
        "//tachyon/c:export",
        "//tachyon/c/base:type_traits_forward",
        "//tachyon/c/math/finite_fields/baby_bear",
        "//tachyon/crypto/challenger:duplex_challenger",
        "//tachyon/crypto/hashes/sponge/poseidon2",
        "//tachyon/crypto/hashes/sponge/poseidon2:poseidon2_params",
        "//tachyon/crypto/hashes/sponge/poseidon2/param_traits:poseidon2_baby_bear",
    ],
)

tachyon_cc_library(
    name = "baby_bear_poseidon2_fields",
    hdrs = ["baby_bear_poseidon2_fields.h"],
    deps = [
        "//tachyon/math/finite_fields/baby_bear:baby_bear4",
        "//tachyon/math/finite_fields/baby_bear:packed_baby_bear4",
    ],
)

tachyon_cc_library(
    name = "baby_bear_poseidon2_field_merkle_tree",
    srcs = ["baby_bear_poseidon2_field_merkle_tree.cc"],
    hdrs = [
        "baby_bear_poseidon2_field_merkle_tree.h",
        "baby_bear_poseidon2_field_merkle_tree_type_traits.h",
    ],
    deps = [
        ":baby_bear_poseidon2_constants",
        "//tachyon/base:auto_reset",
        "//tachyon/base/buffer",
        "//tachyon/c:export",
        "//tachyon/c/base:type_traits_forward",
        "//tachyon/crypto/commitments/merkle_tree/field_merkle_tree",
        "//tachyon/math/finite_fields/baby_bear",
    ],
)

tachyon_cc_library(
    name = "baby_bear_poseidon2_field_merkle_tree_vec",
    srcs = ["baby_bear_poseidon2_field_merkle_tree_vec.cc"],
    hdrs = [
        "baby_bear_poseidon2_field_merkle_tree_vec.h",
        "baby_bear_poseidon2_field_merkle_tree_vec_type_traits.h",
    ],
    deps = [
        ":baby_bear_poseidon2_constants",
        ":baby_bear_poseidon2_field_merkle_tree",
        "//tachyon/base/containers:container_util",
        "//tachyon/c:export",
        "//tachyon/c/base:type_traits_forward",
        "//tachyon/crypto/commitments/merkle_tree/field_merkle_tree",
        "//tachyon/math/finite_fields/baby_bear",
        "@com_google_absl//absl/debugging:leak_check",
    ],
)

tachyon_cc_library(
    name = "baby_bear_poseidon2_hintable",
    hdrs = ["baby_bear_poseidon2_hintable.h"],
    deps = [
        ":baby_bear_poseidon2_fields",
        ":block",
        "//tachyon/base/containers:container_util",
        "//tachyon/crypto/challenger:duplex_challenger",
        "//tachyon/crypto/commitments/fri:fri_proof",
        "//tachyon/math/finite_fields/baby_bear",
        "//tachyon/math/matrix:matrix_types",
    ],
)

tachyon_cc_library(
    name = "baby_bear_poseidon2_lde_vec",
    srcs = ["baby_bear_poseidon2_lde_vec.cc"],
    hdrs = [
        "baby_bear_poseidon2_lde_vec.h",
        "baby_bear_poseidon2_lde_vec_type_traits.h",
    ],
    deps = [
        "//tachyon/c:export",
        "//tachyon/c/base:type_traits_forward",
        "//tachyon/c/math/finite_fields/baby_bear",
        "//tachyon/math/matrix:matrix_types",
    ],
)

tachyon_cc_library(
    name = "baby_bear_poseidon2_opened_values",
    srcs = ["baby_bear_poseidon2_opened_values.cc"],
    hdrs = [
        "baby_bear_poseidon2_opened_values.h",
        "baby_bear_poseidon2_opened_values_type_traits.h",
    ],
    deps = [
        "//tachyon/base:auto_reset",
        "//tachyon/base/buffer",
        "//tachyon/c:export",
        "//tachyon/c/base:type_traits_forward",
        "//tachyon/c/math/finite_fields/baby_bear:baby_bear4",
    ],
)

tachyon_cc_library(
    name = "baby_bear_poseidon2_opening_points",
    srcs = ["baby_bear_poseidon2_opening_points.cc"],
    hdrs = [
        "baby_bear_poseidon2_opening_points.h",
        "baby_bear_poseidon2_opening_points_type_traits.h",
    ],
    deps = [
        "//tachyon/c:export",
        "//tachyon/c/base:type_traits_forward",
        "//tachyon/c/math/finite_fields/baby_bear:baby_bear4",
    ],
)

tachyon_cc_library(
    name = "baby_bear_poseidon2_two_adic_fri",
    srcs = [
        "baby_bear_poseidon2_fri_proof.cc",
        "baby_bear_poseidon2_two_adic_fri.cc",
    ],
    hdrs = [
        "baby_bear_poseidon2_fri_proof.h",
        "baby_bear_poseidon2_fri_proof_type_traits.h",
        "baby_bear_poseidon2_two_adic_fri.h",
        "baby_bear_poseidon2_two_adic_fri_type_traits.h",
    ],
    deps = [
        ":baby_bear_poseidon2_commitment_vec",
        ":baby_bear_poseidon2_constants",
        ":baby_bear_poseidon2_domains",
        ":baby_bear_poseidon2_duplex_challenger",
        ":baby_bear_poseidon2_field_merkle_tree",
        ":baby_bear_poseidon2_field_merkle_tree_vec",
        ":baby_bear_poseidon2_fields",
        ":baby_bear_poseidon2_hintable",
        ":baby_bear_poseidon2_lde_vec",
        ":baby_bear_poseidon2_opened_values",
        ":baby_bear_poseidon2_opening_points",
        "//tachyon/base:auto_reset",
        "//tachyon/base/buffer",
        "//tachyon/c:export",
        "//tachyon/c/base:type_traits_forward",
        "//tachyon/c/crypto/commitments/fri:two_adic_fri_impl",
        "//tachyon/c/math/finite_fields/baby_bear",
        "//tachyon/c/math/finite_fields/baby_bear:baby_bear4",
        "//tachyon/c/math/matrix:baby_bear_row_major_matrix",
        "//tachyon/crypto/challenger:duplex_challenger",
        "//tachyon/crypto/commitments/fri:two_adic_fri",
        "//tachyon/crypto/commitments/fri:two_adic_multiplicative_coset",
        "//tachyon/crypto/commitments/merkle_tree/field_merkle_tree:extension_field_merkle_tree_mmcs",
        "//tachyon/crypto/commitments/merkle_tree/field_merkle_tree:field_merkle_tree_mmcs",
        "//tachyon/crypto/hashes/sponge:padding_free_sponge",
        "//tachyon/crypto/hashes/sponge:truncated_permutation",
        "//tachyon/crypto/hashes/sponge/poseidon2",
        "//tachyon/crypto/hashes/sponge/poseidon2:poseidon2_params",
        "//tachyon/crypto/hashes/sponge/poseidon2/param_traits:poseidon2_baby_bear",
    ],
)

tachyon_cc_library(
    name = "block",
    hdrs = ["block.h"],
    deps = [
        "//tachyon/base/buffer:copyable",
        "//tachyon/base/strings:string_util",
        "//tachyon/base/types:always_false",
        "//tachyon/math/finite_fields:finite_field_traits",
    ],
)

tachyon_cc_library(
    name = "sp1",
    deps = [":baby_bear_poseidon2_two_adic_fri"],
)

tachyon_cc_unittest(
    name = "sp1_unittests",
    srcs = [
        "baby_bear_poseidon2_duplex_challenger_unittest.cc",
        "baby_bear_poseidon2_hintable_unittest.cc",
        "baby_bear_poseidon2_opened_values_unittest.cc",
        "baby_bear_poseidon2_two_adic_fri_unittest.cc",
        "block_unittest.cc",
    ],
    deps = [
        ":baby_bear_poseidon2_hintable",
        ":sp1",
        "//tachyon/base/buffer:vector_buffer",
        "//tachyon/math/finite_fields/test:finite_field_test",
    ],
)
